﻿namespace TextFiles
{
    using System;
    using System.IO;

    class ReplaceSubstringOccurrences
    {
        // 1.2.12.07. Write a program that replaces all occurrences of the substring "start" with the
        // substring "finish" in a text file. Ensure it will work with large files (e.g. 100 MB).

        static void Main()
        {
            StreamReader input = new StreamReader(@"../../input.txt");
            StreamWriter output = new StreamWriter(@"../../output.txt");

            using (input)
            {
                using (output)
                {
                    string line = input.ReadLine().ToLower();
                    while (line != null)
                    {
                        line = line.Replace("start", "finish");
                        output.WriteLine(line);
                        line = input.ReadLine();
                    }
                }
            } 
        }
    }
}